<template>
	<view class="content">
		<button @click="hello">调用云函数</button>
		<input type="number" v-model="num1" />
		<input type="number" v-model="num2" />
		
		<button v-for="(item,index) in mathDels" @click="maths(item)" :key="index">{{item}}</button>

		<text>{{result}}</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				num1:0,
				num2:0,
				result:0,
				mathDels:['add','reduce','mul','division']
			}
		},
		onLoad() {
			
		},
		methods: {
			async maths(type){
				const maths = uniCloud.importObject('maths');
				let res = await maths[type](parseInt(this.num1),parseInt(this.num2))
				this.result = res
			},
			hello(){
				uniCloud.callFunction({
					name:'hello',
					success(res) {
						console.log(res.result.msg)
					}
				})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.map-mine {
		width: 100%;
		height: 50vh;
	}
</style>
